<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增转换')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-trans-add">
<!--            <div class="form-group">
                <label class="col-sm-3 control-label is-required">选择转换：</label>
                <div class="col-sm-8">
                    <input name="transName" class="form-control" type="text"  onclick="chooseTrans();" required>
                </div>
            </div>-->
            <input name="transRepositoryId"  class="form-control" type="hidden"  id="transRepositoryId"   required>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">选择转换：</label>
                <div class="col-sm-8">
                    <input name="transName"  class="form-control" type="text"  id="treeName" onclick="chooseTrans();" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">转换描述：</label>
                <div class="col-sm-8">
                    <textarea name="transDescription" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">转换类型(file,ftp,sftp)：</label>
                <div class="col-sm-8">
                    <select name="transType" class="form-control m-b" th:with="type=${@dict.getType('repository_type')}"  disabled="disabled">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">路径：</label>
                <div class="col-sm-8">
                    <input name="transPath" id="transPath" class="form-control" type="text" required readonly>
                </div>
            </div>
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">所属资源库id：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="transRepositoryId" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
            <div class="form-group">    
                <label class="col-sm-3 control-label">日志级别：</label>
                <div class="col-sm-8">
                    <select name="transLogLevel" class="form-control m-b" th:with="type=${@dict.getType('kettle_log_level')}" >
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
<!--            <div class="form-group">
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box">
                        <input type="radio" name="transStatus" value="">
                        <label th:for="transStatus" th:text="未知"></label>
                    </div>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
                </div>
            </div>-->
<!--            <div class="form-group">
                <label class="col-sm-3 control-label">是否监控：</label>
                <div class="col-sm-8">
                    <label class="radio-box">
                        <input type="radio" checked="" value=1 id="optionsRadios1" name="isMonitorEnabled">是</label>
                    <label class="radio-box">
                        <input type="radio" value=0 id="optionsRadios2" name="isMonitorEnabled">否</label>
                </div>
            </div>-->

<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label">角色key：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <textarea name="roleKey" class="form-control" placeholder="可以执行该转换的角色组合,用','连接,如:admin,guest,表示admin角色和guest角色都可以执行该转换"></textarea>-->
<!--                </div>-->
<!--            </div>-->
            <div class="form-group">
                <label class="col-sm-3 control-label">角色key:</label>
                <div class="col-sm-8">
                    <select class="form-control noselect2 selectpicker  m-b"    name="roleKey"  data-none-selected-text="可以执行该转换的角色组合" multiple  >
                        <option th:each="allRoles:${allRoles}" th:value="${allRoles}" th:text="${allRoles}"   ></option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">
        $.fn.selectpicker.Constructor.DEFAULTS.liveSearch=true
        var prefix = ctx + "kettle/trans"
        $("#form-trans-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-trans-add').serialize());
            }
        }

        $("input[name='createdTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        function chooseTrans(){
            var treeId = $("#treeId").val();
            //var repoid = $.common.isEmpty(treeId) ? "999999" : $("#treeId").val();
            var type="trans";
            var url = ctx + "kettle/repository/selectRepositoryTree/"+type
            var options = {
                title: '选择资源库',
                width: "380",
                url: url,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var tree = layero.find("iframe")[0].contentWindow.$._tree;
            var body = $.modal.getChildFrame(index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            $("#transRepositoryId").val(body.find('#transRepositoryId').val());
            $("#transPath").val(body.find('#transPath').val());


            $.modal.close(index);
        }
    </script>
</body>
</html>